---
title: "Mario Kart Speedruns"
output:
flexdashboard::flex_dashboard:
orientation: columns
navbar:
- { title: "Time Trials", href: "tt.hrml", align: right}
- { icon: "fas fa-home", href: "index.html", align: right}
theme:
bootswatch: minty
favicon: blueshell.png
source_code: embed
---
```{bash llstocsv, include=FALSE}
# Convert all lss files in folder to csv
MK8D_trk2csv ./_data/splits ./_data/splits MK8D_trks.csv
```
```{r libs}
library(tidyverse)
library(lubridate)
library(plotly)
```
```{r}
source("lsstocsv.R")
sr <- sr %>%
group_by(cat2, track) %>%
mutate(sd = sd(time)) %>%
ungroup()
```
# 48 Tracks
## Col 1 {data-width="350"}
### Track Time Distributions
```{r}
violin_48 <- sr %>%
filter(cat2 == "Original 48" & track != "Start") %>%
ggplot(aes(factor(track), time)) +
geom_violin(scale = "width",
aes(fill = sd, color=sd),
alpha = .7) +
stat_summary(fun = "mean", geom = "crossbar", size = .2, aes(color = sd)) +
stat_summary(fun = "median", geom = "point", size = .4) +
scale_fill_gradient(low = "darkcyan", high = "plum") +
scale_color_gradient(low = "darkcyan", high = "plum") +
scale_y_time() +
scale_x_discrete(limits = rev) +
coord_flip() +
labs(x = "",
y = "Time") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45,
hjust = 0.98,
vjust = 0.9),
axis.text = element_text(size = 8),
axis.ticks = element_line(size = .2),
panel.grid = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none")
ggplotly(violin_48)
```
## Col 2 {.tabset}
### Improvement
```{r}
runs_48 <- runs %>%
filter(cat2 == "Original 48") %>%
group_by(cat2, track) %>%
mutate(sd = sd(time)) %>%
ungroup()
colors_48 <- color_range(length(unique(runs_48$runNO)))
runs_48 <- runs_48 %>%
mutate(clr = ifelse(runNO == 0, "grey", colors_48[runs_48$runNO]))
```
```{r}
traces_48 <- ggplot() +
geom_violin(data = runs_48[which(runs_48$runNO != 0), ],
aes(
factor(track),
maxdiff,
color = NA,
fill = sd,
alpha = .1),
scale = "width") +
geom_line(data = runs_48, aes(
factor(track),
maxdiff,
group = runNO,
color = clr,
alpha = runNO,
text = label
)) +
geom_point(data = runs_48[which(runs_48$pts > 0),], aes(
factor(track),
maxdiff,
size = pts,
color = "tomato",
text = label)) +
scale_y_time() +
scale_fill_gradient(low = "darkcyan", high = "plum") +
scale_size_continuous(range = c(.05, 2.75)) +
scale_color_identity() +
scale_alpha_continuous(range = c(.35, .8)) +
labs(x = "",
y = "") +
theme_minimal() +
theme(
axis.text.x = element_text(
angle = 45,
hjust = 0.98,
vjust = 0.9
),
axis.text = element_text(size = 8),
axis.ticks = element_line(size = .2),
panel.grid = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none"
)
ggplotly(traces_48, tooltip = "text") %>%
layout(margin = list(t = 60),
title = list(text = paste0('Improvement from Slowest Run',
'<br><sup>48 Tracks, 150cc, No Items</sup>'))) %>%
style(hoverinfo = "skip", traces = 0:length(unique(runs_48$track)))
```
### Run Time
```{r}
run_time_48 <- run_time %>%
filter(cat2 == "Original 48") %>%
mutate(label = paste0(
"<b>Run #",
runNO,
" ",
date,
"</b>",
"<br>",
round(seconds_to_period(cumsum), 2)
)) %>%
ggplot(aes(runNO, cumsum, color = "goldenrod")) +
geom_line() +
geom_point(aes(text = label)) +
scale_y_time(labels = scales::label_time()) +
scale_x_continuous(labels = scales::label_number(accuracy = 1)) +
scale_color_identity() +
labs(x = "Run Number", y = "") +
theme_minimal() +
theme(axis.ticks = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none")
ggplotly(run_time_48, tooltip = "text")
```
# Nitro Tracks {data-navmenu="16 Tracks"}
## Col 1 {data-width="350"}
### Track Time Distributions
```{r}
violin_nt <- sr %>%
filter(cat2 == "Nitro Tracks" & track != "Start") %>%
ggplot(aes(factor(track), time)) +
geom_violin(scale = "width",
aes(fill = sd, color=sd),
alpha = .7) +
stat_summary(fun = "mean", geom = "crossbar", size = .2, aes(color = sd)) +
stat_summary(fun = "median", geom = "point", size = .4) +
scale_fill_gradient(low = "darkcyan", high = "plum") +
scale_color_gradient(low = "darkcyan", high = "plum") +
scale_y_time() +
scale_x_discrete(limits = rev) +
coord_flip() +
labs(x = "",
y = "Time") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45,
hjust = 0.98,
vjust = 0.9),
axis.text = element_text(size = 8),
axis.ticks = element_line(size = .2),
panel.grid = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none")
ggplotly(violin_nt)
```
## Col 2 {.tabset}
### Improvement
```{r}
runs_nt <- runs %>%
filter(cat2 == "Nitro Tracks") %>%
group_by(cat2, track) %>%
mutate(sd = sd(time)) %>%
ungroup()
colors_nt <- color_range(length(unique(runs_nt$runNO)))
runs_nt <- runs_nt %>%
mutate(clr = ifelse(runNO == 0, "grey", colors_nt[runs_nt$runNO]))
```
```{r}
traces_nt <- ggplot() +
geom_violin(data = runs_nt[which(runs_nt$runNO != 0),],
aes(
factor(track),
maxdiff,
color = NA,
fill = sd,
alpha = .1),
scale = "width") +
geom_line(data = runs_nt, aes(
factor(track),
maxdiff,
group = runNO,
color = clr,
alpha = runNO,
text = label
)) +
geom_point(data = runs_nt[which(runs_nt$pts > 0),], aes(
factor(track),
maxdiff,
size = pts,
color = "tomato",
text = label)) +
scale_y_time() +
scale_fill_gradient(low = "darkcyan", high = "plum") +
scale_size_continuous(range = c(.05, 2.75)) +
scale_color_identity() +
scale_alpha_continuous(range = c(.35, .8)) +
labs(x = "",
y = "") +
theme_minimal() +
theme(
axis.text.x = element_text(
angle = 45,
hjust = 0.98,
vjust = 0.9
),
axis.text = element_text(size = 8),
axis.ticks = element_line(size = .2),
panel.grid = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none"
)
ggplotly(traces_nt, tooltip = "text") %>%
layout(margin = list(t = 60),
title = list(text = paste0('Improvement from Slowest Run',
'<br><sup>Nitro Tracks, 150cc, No Items</sup>'))) %>%
style(hoverinfo = "skip", traces = 0:length(unique(runs_nt$track)))
```
### Run Time
```{r}
run_time_nt <- run_time %>%
filter(cat2 == "Nitro Tracks") %>%
mutate(label = paste0(
"<b>Run #",
runNO,
" ",
date,
"</b>",
"<br>",
round(seconds_to_period(cumsum), 2)
)) %>%
ggplot(aes(runNO, cumsum, color = "goldenrod")) +
geom_line() +
geom_point(aes(text = label)) +
scale_y_time(labels = scales::label_time()) +
scale_x_continuous(labels = scales::label_number(accuracy = 1)) +
scale_color_identity() +
labs(x = "Run Number", y = "") +
theme_minimal() +
theme(axis.ticks = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none")
ggplotly(run_time_nt, tooltip = "text")
```
# Nitro Cups {data-navmenu="Cups"}
## Col 1 {data-width="350"}
### Track Time Distributions
```{r}
violin_nc <- sr %>%
filter(cat1 == "Nitro Cups" & track != "Start") %>%
ggplot(aes(factor(track), time)) +
geom_violin(scale = "width",
aes(fill = sd, color=sd),
alpha = .7) +
stat_summary(fun = "mean", geom = "crossbar", size = .2, aes(color = sd)) +
stat_summary(fun = "median", geom = "point", size = .4) +
scale_fill_gradient(low = "darkcyan", high = "plum") +
scale_color_gradient(low = "darkcyan", high = "plum") +
scale_y_time() +
scale_x_discrete(limits = rev) +
coord_flip() +
labs(x = "",
y = "Time") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45,
hjust = 0.98,
vjust = 0.9),
axis.text = element_text(size = 8),
axis.ticks = element_line(size = .2),
panel.grid = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none")
ggplotly(violin_nc)
```
## Col 2 {.tabset}
### Improvement
```{r}
runs_nc <- runs %>%
filter(cat1 == "Nitro Cups") %>%
group_by(cat1, track) %>%
mutate(sd = sd(time)) %>%
ungroup()
colors_nc <- color_range(length(unique(runs_nc$runNO)))
runs_nc <- runs_nc %>%
mutate(clr = ifelse(runNO == 0, "grey", colors_nc[runs_nc$runNO]))
```
```{r}
traces_nc <- ggplot() +
geom_violin(data = runs_nc[which(runs_nc$runNO != 0), ],
aes(
factor(track),
maxdiff,
color = NA,
fill = sd,
alpha = .1),
scale = "width") +
geom_line(data = runs_nc, aes(
factor(track),
maxdiff,
group = runNO,
color = clr,
alpha = runNO,
text = label
)) +
geom_point(data = runs_nc[which(runs_nc$pts > 0),], aes(
factor(track),
maxdiff,
size = pts,
color = "tomato",
text = label)) +
scale_y_time() +
scale_fill_gradient(low = "darkcyan", high = "plum") +
scale_size_continuous(range = c(.05, 2.75)) +
scale_color_identity() +
scale_alpha_continuous(range = c(.35, .8)) +
facet_wrap(~cat2, scales = "free") +
labs(x = "",
y = "") +
theme_minimal() +
theme(
axis.text.x = element_text(
angle = 45,
hjust = 0.98,
vjust = 0.9
),
axis.text = element_text(size = 8),
axis.ticks = element_line(size = .2),
panel.grid = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none"
)
ggplotly(traces_nc, tooltip = "text") %>%
layout(margin = list(b = 110)) %>%
style(hoverinfo = "skip", traces = 0:length(unique(runs_nc$track)))
```
### Run Time
```{r}
run_time_nc <- run_time %>%
filter(cat1 == "Nitro Cups") %>%
mutate(label = paste0(
"<b>Run #",
runNO,
" ",
date,
"</b>",
"<br>",
round(seconds_to_period(cumsum), 2)
)) %>%
ggplot(aes(runNO, cumsum, color = "goldenrod")) +
geom_line() +
geom_point(aes(text = label)) +
scale_y_time(labels = scales::label_time()) +
scale_x_continuous(labels = scales::label_number(accuracy = 1)) +
scale_color_identity() +
facet_wrap(~cat2, scales = "free") +
labs(x = "Run Number", y = "") +
theme_minimal() +
theme(axis.ticks = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none")
ggplotly(run_time_nc, tooltip = "text")
```
# Retro Cups {data-navmenu="Cups"}
## Col 1 {data-width="350"}
### Track Time Distributions
```{r}
violin_rc <- sr %>%
filter(cat1 == "Retro Cups" & track != "Start") %>%
ggplot(aes(factor(track), time)) +
geom_violin(scale = "width",
aes(fill = sd, color=sd),
alpha = .7) +
stat_summary(fun = "mean", geom = "crossbar", size = .2, aes(color = sd)) +
stat_summary(fun = "median", geom = "point", size = .4) +
scale_fill_gradient(low = "darkcyan", high = "plum") +
scale_color_gradient(low = "darkcyan", high = "plum") +
scale_y_time() +
scale_x_discrete(limits = rev) +
coord_flip() +
labs(x = "",
y = "Time") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45,
hjust = 0.98,
vjust = 0.9),
axis.text = element_text(size = 8),
axis.ticks = element_line(size = .2),
panel.grid = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none")
ggplotly(violin_rc)
```
## Col 2 {.tabset}
### Improvement
```{r}
runs_rc <- runs %>%
filter(cat1 == "Retro Cups") %>%
group_by(cat1, track) %>%
mutate(sd = sd(time)) %>%
ungroup()
colors_rc <- color_range(length(unique(runs_rc$runNO)))
runs_rc <- runs_rc %>%
mutate(clr = ifelse(runNO == 0, "grey", colors_rc[runs_rc$runNO]))
```
```{r}
traces_rc <- ggplot() +
geom_violin(data = runs_rc[which(runs_rc$runNO != 0), ],
aes(
factor(track),
maxdiff,
color = NA,
fill = sd,
alpha = .1),
scale = "width") +
geom_line(data = runs_rc, aes(
factor(track),
maxdiff,
group = runNO,
color = clr,
alpha = runNO,
text = label
)) +
geom_point(data = runs_rc[which(runs_rc$pts > 0),], aes(
factor(track),
maxdiff,
size = pts,
color = "tomato",
text = label)) +
scale_y_time() +
scale_fill_gradient(low = "darkcyan", high = "plum") +
scale_size_continuous(range = c(.05, 2.75)) +
scale_color_identity() +
scale_alpha_continuous(range = c(.35, .8)) +
facet_wrap(~cat2, scales = "free") +
labs(x = "",
y = "") +
theme_minimal() +
theme(
axis.text.x = element_text(
angle = 45,
hjust = 0.98,
vjust = 0.9
),
axis.text = element_text(size = 8),
axis.ticks = element_line(size = .2),
panel.grid = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none"
)
ggplotly(traces_rc, tooltip = "text") %>%
layout(margin = list(b = 110)) %>%
style(hoverinfo = "skip", traces = 0:length(unique(runs_rc$track)))
```
### Run Time
```{r}
run_time_rc <- run_time %>%
filter(cat1 == "Retro Cups") %>%
mutate(label = paste0(
"<b>Run #",
runNO,
" ",
date,
"</b>",
"<br>",
round(seconds_to_period(cumsum), 2)
)) %>%
ggplot(aes(runNO, cumsum, color = "goldenrod")) +
geom_line() +
geom_point(aes(text = label)) +
scale_y_time(labels = scales::label_time()) +
scale_x_continuous(labels = scales::label_number(accuracy = 1)) +
scale_color_identity() +
facet_wrap(~cat2, scales = "free") +
labs(x = "Run Number", y = "") +
theme_minimal() +
theme(axis.ticks = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none")
ggplotly(run_time_rc, tooltip = "text")
```
# Bonus Cups {data-navmenu="Cups"}
## Col 1 {data-width="350"}
### Track Time Distributions
```{r}
violin_bc <- sr %>%
filter(cat1 == "Bonus Cups" & track != "Start") %>%
ggplot(aes(factor(track), time)) +
geom_violin(scale = "width",
aes(fill = sd, color=sd),
alpha = .7) +
stat_summary(fun = "mean", geom = "crossbar", size = .2, aes(color = sd)) +
stat_summary(fun = "median", geom = "point", size = .4) +
scale_fill_gradient(low = "darkcyan", high = "plum") +
scale_color_gradient(low = "darkcyan", high = "plum") +
scale_y_time() +
scale_x_discrete(limits = rev) +
coord_flip() +
labs(x = "",
y = "Time") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45,
hjust = 0.98,
vjust = 0.9),
axis.text = element_text(size = 8),
axis.ticks = element_line(size = .2),
panel.grid = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none")
ggplotly(violin_bc)
```
## Col 2 {.tabset}
### Improvement
```{r}
runs_bc <- runs %>%
filter(cat1 == "Bonus Cups") %>%
group_by(cat1, track) %>%
mutate(sd = sd(time)) %>%
ungroup()
colors_bc <- color_range(length(unique(runs_bc$runNO)))
runs_bc <- runs_bc %>%
mutate(clr = ifelse(runNO == 0, "grey", colors_bc[runs_bc$runNO]))
```
```{r}
traces_bc <- ggplot() +
geom_violin(data = runs_bc[which(runs_bc$runNO != 0), ],
aes(
factor(track),
maxdiff,
color = NA,
fill = sd,
alpha = .1),
scale = "width") +
geom_line(data = runs_bc, aes(
factor(track),
maxdiff,
group = runNO,
color = clr,
alpha = runNO,
text = label
)) +
geom_point(data = runs_bc[which(runs_bc$pts > 0),], aes(
factor(track),
maxdiff,
size = pts,
color = "tomato",
text = label)) +
scale_y_time() +
scale_fill_gradient(low = "darkcyan", high = "plum") +
scale_size_continuous(range = c(.05, 2.75)) +
scale_color_identity() +
scale_alpha_continuous(range = c(.35, .8)) +
facet_wrap(~cat2, scales = "free") +
labs(x = "",
y = "") +
theme_minimal() +
theme(
axis.text.x = element_text(
angle = 45,
hjust = 0.98,
vjust = 0.9
),
axis.text = element_text(size = 8),
axis.ticks = element_line(size = .2),
panel.grid = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none"
)
ggplotly(traces_bc, tooltip = "text") %>%
layout(margin = list(b = 110)) %>%
style(hoverinfo = "skip", traces = 0:length(unique(runs_bc$track)))
```
### Run Time
```{r}
run_time_bc <- run_time %>%
filter(cat1 == "Bonus Cups") %>%
mutate(label = paste0(
"<b>Run #",
runNO,
" ",
date,
"</b>",
"<br>",
round(seconds_to_period(cumsum), 2)
)) %>%
ggplot(aes(runNO, cumsum, color = "goldenrod")) +
geom_line() +
geom_point(aes(text = label)) +
scale_y_time(labels = scales::label_time()) +
scale_x_continuous(labels = scales::label_number(accuracy = 1)) +
scale_color_identity() +
facet_wrap(~cat2, scales = "free") +
labs(x = "Run Number", y = "") +
theme_minimal() +
theme(axis.ticks = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none")
ggplotly(run_time_bc, tooltip = "text")
```
# DLC Cups {data-navmenu="Cups"}
## Col 1 {data-width="350"}
### Track Time Distributions
```{r}
violin_dc <- sr %>%
filter(cat1 == "DLC Cups" & track != "Start") %>%
ggplot(aes(factor(track), time)) +
geom_violin(scale = "width",
aes(fill = sd, color=sd),
alpha = .7) +
stat_summary(fun = "mean", geom = "crossbar", size = .2, aes(color = sd)) +
stat_summary(fun = "median", geom = "point", size = .4) +
scale_fill_gradient(low = "darkcyan", high = "plum") +
scale_color_gradient(low = "darkcyan", high = "plum") +
scale_y_time() +
scale_x_discrete(limits = rev) +
coord_flip() +
labs(x = "",
y = "Time") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45,
hjust = 0.98,
vjust = 0.9),
axis.text = element_text(size = 8),
axis.ticks = element_line(size = .2),
panel.grid = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none")
ggplotly(violin_dc)
```
## Col 2 {.tabset}
### Improvement
```{r}
runs_dc <- runs %>%
filter(cat1 == "DLC Cups") %>%
group_by(cat1, track) %>%
mutate(sd = sd(time)) %>%
ungroup()
colors_dc <- color_range(length(unique(runs_dc$runNO)))
runs_dc <- runs_dc %>%
mutate(clr = ifelse(runNO == 0, "grey", colors_dc[runs_dc$runNO]))
```
```{r}
traces_dc <- ggplot() +
geom_violin(data = runs_dc[which(runs_dc$runNO != 0), ],
aes(
factor(track),
maxdiff,
color = NA,
fill = sd,
alpha = .1),
scale = "width") +
geom_line(data = runs_dc, aes(
factor(track),
maxdiff,
group = runNO,
color = clr,
alpha = runNO,
text = label
)) +
geom_point(data = runs_dc[which(runs_dc$pts > 0),], aes(
factor(track),
maxdiff,
size = pts,
color = "tomato",
text = label)) +
scale_y_time() +
scale_fill_gradient(low = "darkcyan", high = "plum") +
scale_size_continuous(range = c(.05, 2.75)) +
scale_color_identity() +
scale_alpha_continuous(range = c(.35, .8)) +
facet_wrap(~cat2, scales = "free") +
labs(x = "",
y = "") +
theme_minimal() +
theme(
axis.text.x = element_text(
angle = 45,
hjust = 0.98,
vjust = 0.9
),
axis.text = element_text(size = 8),
axis.ticks = element_line(size = .2),
panel.grid = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none"
)
ggplotly(traces_dc, tooltip = "text") %>%
layout(margin = list(b = 110)) %>%
style(hoverinfo = "skip", traces = 0:length(unique(runs_dc$track)))
```
### Run Time
```{r}
run_time_dc <- run_time %>%
filter(cat1 == "DLC Cups") %>%
mutate(label = paste0(
"<b>Run #",
runNO,
" ",
date,
"</b>",
"<br>",
round(seconds_to_period(cumsum), 2)
)) %>%
ggplot(aes(runNO, cumsum, color = "goldenrod")) +
geom_line() +
geom_point(aes(text = label)) +
scale_y_time(labels = scales::label_time()) +
scale_x_continuous(labels = scales::label_number(accuracy = 1)) +
scale_color_identity() +
facet_wrap(~cat2, scales = "free") +
labs(x = "Run Number", y = "") +
theme_minimal() +
theme(axis.ticks = element_line(size = .2),
panel.border = element_rect(fill = NA, size = .2),
legend.position = "none")
ggplotly(run_time_dc, tooltip = "text")
```